
package com.xebest.web.service;

import com.xebest.common.enums.cms.SysCmsPagePlatEnum;
import com.xebest.web.form.XeVenOrderForm;
import com.xebest.web.form.XeVenOrderFromVo;
import com.xebest.web.form.XeVenOrderRelationPurchForm;
import com.xebest.web.form.XeVenSplitOrderForm;
import com.xebest.web.model.XeVenOrderInfoDetailEntity;
import com.xebest.web.model.XeVenOrderInfoEntity;
import com.xebest.web.model.XeVenOrderLogistics;
import com.xebest.web.model.XeVenStoreInfoEntity;
import com.xebest.web.view.ErpUserInfo;
import com.xebest.web.view.XeVenOrderView;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单相关操作
 *
 * @author ruancz
 */
public interface XeVenOrderService {

    /**
     * 查询订单列表接口
     *
     * @author ruancz
     */
    List<XeVenOrderView> queryOrderInfoList(XeVenOrderForm xeVenOrderForm, ErpUserInfo userInfo);

    /**
     * 查新订单明细
     *
     * @author ruancz
     */
    Map<String, Object> queryOrderInfoDetail(String orderId, ErpUserInfo userInfo);

    /**
     * 更新订单
     *
     * @author ruancz
     */
    int updateOrderInfo(XeVenOrderForm forms, ErpUserInfo userInfo) throws Exception;

    /**
     * 取消订单
     *
     * @author ruancz
     */
    void cancelOrder(List<XeVenOrderForm> formList, ErpUserInfo userInfo, String requestIP) throws Exception;

    /**
     * 修改特批优惠金额
     *
     * @author ruancz
     */
    int updateSpecialDisamount(List<XeVenOrderForm> xeVenOrderForm, ErpUserInfo userInfo, String requestIP) throws Exception;

    /**
     * 批量审核订单
     *
     * @author ruancz
     */
    void updateBatchAuditOrder(List<XeVenOrderForm> formList, ErpUserInfo userInfo, String requestIP) throws Exception;

    /**
     * 异常订单列表  更新异常订单
     *
     * @author ruancz
     */
    Map<String, Object> updateExceptionOrder(List<XeVenOrderForm> formList, ErpUserInfo userInfo) throws Exception;

    /**
     * 库存占用以或释放
     *
     * @author ruancz
     */
    boolean fallbackInventory(XeVenStoreInfoEntity storeInfo, List<XeVenOrderInfoDetailEntity> orderInfoDetail, String storeId, String userCode, ErpUserInfo userInfo) throws Exception;

    /**
     * 取消审核订单
     *
     * @author ruancz
     */
    Map<String, Object> updateUnBatchAuditOrder(List<XeVenOrderForm> formList, ErpUserInfo userInfo, String requestIP) throws Exception;

    /**
     * 订单发货更新订单状态接口
     *
     * @author 李贝贝
     */
    int updateXeVenOrder(XeVenOrderInfoEntity orderInfoEntity) throws Exception;

    /**
     * 判断仓库库存是否足够
     *
     * @author ruancz
     */
    int judeExceptionOrder(XeVenOrderInfoEntity venOrderInfoEntity, XeVenStoreInfoEntity storeInfo,
                           List<XeVenOrderInfoDetailEntity> orderInfoDetailList) throws Exception;

    /**
     * 批量修改订单实发数量
     *
     * @author ruancz
     */
    Map<String, Object> updateOrderRealSendNum(ErpUserInfo userInfo, List<XeVenSplitOrderForm> xeVenSplitOrderForm, String requestIP) throws Exception;

    /**
     * 查询订单明细
     *
     * @author ruancz
     */
    List<XeVenOrderInfoDetailEntity> getOrderDetailByParam(Map<String, Object> params);

    /**
     * 锁单/解锁订单接口
     *
     * @author ruancz
     */
    int updateLockOrderInfo(List<XeVenOrderForm> orderForm, ErpUserInfo userInfo, String xeStrOne) throws Exception;

    /**
     * 修改运费金额
     *
     * @author ruancz
     */
    int updateFreAmount(XeVenOrderForm xeVenOrderForm, ErpUserInfo userInfo, String requestIP) throws Exception;

    /**
     * 修改仓库
     *
     * @author ruancz
     */
    Map<String, Object> updateOrderStore(List<XeVenOrderForm> formList, ErpUserInfo userInfo, String requestIP) throws Exception;

    /**
     * 单条修改订单实发数量
     *
     * @author ruancz
     */
    Map<String, Object> updateOrderSendNum(ErpUserInfo userInfo, XeVenSplitOrderForm xeVenSplitOrderForm, String requestIP,SysCmsPagePlatEnum platEnum) throws Exception;

    /**
     * 修改物流单信息
     */
    int updateOrderLogistics(XeVenOrderLogistics orderLogistics, String storeName) throws Exception;

    /**
     * 订单汇总采购取消审核
     *
     * @author ruancz
     */
    Map<String, Object> cancelAuditSummaryPurch(ErpUserInfo userInfo, List<XeVenOrderForm> xeVenOrderForm, String requestIP) throws Exception;

    /**
     * 订单汇总采购取消审核
     *
     * @author ruancz
     */
    Map<String, Object> countSummaryPurch(ErpUserInfo userInfo, List<XeVenOrderForm> xeVenOrderForm);

    /**
     * 插入汇总采购单
     *
     * @author ruancz
     */
    Map<String, Object> insertSummaryPurch(ErpUserInfo userInfo, XeVenOrderFromVo orderFromVo, String requestIP) throws Exception;

    /**
     * 插入物流单信息
     */
    void insertOrderLogistics(ErpUserInfo userInfo, String orderId, String storeName) throws Exception;

    List<Map<String, Object>> querySalesMan();

    /**
     * @author 李书峰
     */
    Map<String, Object> queryShopYesterdayData(Map<String, Object> map);

    /**
     * @author 李书峰
     */
    BigDecimal queryWaitCheckOrderNum(Map<String, Object> map);

    /**
     * @author 李书峰
     */
    BigDecimal queryExceptionOrderNum(Map<String, Object> map);

    /**
     * @author 李书峰
     */
    BigDecimal queryWaitSendOrderNum(Map<String, Object> map);

    /**
     * @author 李书峰
     */
    BigDecimal queryMonthTotalAmount(Map<String, Object> map);

    /**
     * @author 李书峰
     */
    BigDecimal queryMonthTradeUserNum(Map<String, Object> map);

    /**
     * 添加日志
     */
    void insertMqLog(String logType, String key, String operatorContent, ErpUserInfo userInfo, String ipAddress, String remark);

    /**
     * 统计订单数据
     */
    List<Map<String, Object>> queryCountOrderInfo(XeVenOrderForm form, ErpUserInfo userInfo);

    /**
     * 根据日 月 年等统计订单数
     *
     * @author chenjing
     */
    BigDecimal queryOrderCountByParams(Map<String, Object> map);

    /**
     * 根据日 月 年等统计销售额
     *
     * @author chenjing
     */
    BigDecimal queryMonthTotalAmountByParams(Map<String, Object> map);


    /**
     * 根据日 月 年等统计交易用户数
     *
     * @author chenjing
     */
    BigDecimal queryMonthTradeUserNumByParams(Map<String, Object> map);


    /**
     * 根据日 月 年等统计交易用户数
     *
     * @author chenjing
     */
    List<Map<String, Object>> queryProOrgCountByParams(Map<String, Object> map);

    /**
     * 统计每月的日销售额和订单数
     *
     * @author chenjing
     */
    List<Map<String, Object>> queryOrderCountAmountByParams(Map<String, Object> map);

    /**
     * 订单手动关联采购单
     */
    Map<String, Object> insertOrderRelationPurch(List<XeVenOrderRelationPurchForm> orderRelationPurchForm);

    /**
     * 取消订单提取公共方法
     * 废单 在线支付创建退款单 库存回滚 同步商城  消息推送鲜易商城
     *
     * @param orderInfo 传参(必传) orderId（订单编码）, storeId(仓库编码),payType(支付类型),payStatus(付款状态),cancelRemark(订单取消原因)
     */
    void judeCancelOrder(XeVenOrderInfoEntity orderInfo, ErpUserInfo userInfo) throws Exception;

    /**
     * 根据订单ID查询订单状态
     */
    List<XeVenOrderInfoEntity> queryOrderStatusByOrderId(String orderId);

    /**
     * 鲜易消消乐取消订单
     */
    int cancelOrderByorderId(XeVenOrderInfoEntity orderInfoEntity, String requestIP);

    /**
     * 查询写库订单明细信息
     *
     * @author 李贝贝
     */
    List<XeVenOrderInfoDetailEntity> getWriteOrderDetailByParam(Map<String, Object> params);

    /**
     * 某个产品（spu）在订单记录中被多少条订单占用
     * 订单状态包括 待分配、待审核、待发货 均表示为spu被占用
     *
     * @param spu 产品spu
     * @return 多少个订单中包含此订单
     * @author zhouys
     */
    int spuTakeUpCount(String spu);
}
  
